package com.hhc.repository;

import com.hhc.entity.TeacherCourseAssignment;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository;
import org.springframework.data.jpa.repository.EntityGraph;
import java.util.List;

/**
 * <p>
 *   教师授课任务数据库访问层
 * </p>
 * @author pc
 */
@Repository
public interface TeacherCourseAssignmentRepository extends JpaRepository<TeacherCourseAssignment, Long> {

    boolean existsByCourseId(Long courseId);

    @EntityGraph(attributePaths = { "teacher", "course" })
    List<TeacherCourseAssignment> findByTeacherIdAndSemester(Long teacherId, String semester);

    @EntityGraph(attributePaths = { "teacher", "course" })
    List<TeacherCourseAssignment> findByCourseId(Long courseId);

    boolean existsByTeacherIdAndCourseId(Long teacherId, Long courseId);
}
